home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / chat / ircii-2.8he / ircii-2 / help / FOREACH < prev    next >
Encoding:
Text File  |  1993-05-04  |  1.2 KB  |  46 lines

  1. Usage: FOREACH <structure> <variable> { <commands> }
  2.   This causes <commands> to be executed once for each 
  3.   element in the structure.  The aliases inside the {} 
  4.   are not expanded until execution unless the leading { 
  5.   is quoted like \{
  6.   Here are a couple examples of basic foreach commands.
  7.     assign blue.1 one
  8.     assign blue.2 two 
  9.     assign blue.3 three
  10.     foreach blue ii { echo $ii $blue[$ii] }
  11.   will return
  12.     1 one
  13.     2 two
  14.     3 three
  15.   FOREACH can also be imbedded such as in the following example.
  16.     assign blue.1.1 one one
  17.     assign blue.1.2 one two
  18.     assign blue.2.1 two one
  19.     assign blue.2.2 two two
  20.     alias showblue {
  21.       foreach blue ii
  22.       {
  23.         foreach blue.$ii jj
  24.         {
  25.       echo $ii $jj $blue[$ii][$jj]
  26.         }
  27.       }
  28.     }
  29.   And /showblue returns.. 
  30.     1 1 one one
  31.     1 2 one two 
  32.     2 1 two one
  33.     2 2 two two
  34.  
  35. Note:
  36.   When using this format the {} in the foreach must be on separate 
  37.   lines by themselves.  This is true for IF and WHILE as well.
  38.  
  39.   Notice that variable names 'ii' and 'jj' were used.  Any name can
  40.   be used for the index but keep in mind that single letter vars can
  41.   interfere with the built in single char vars.  See ALIAS special
  42.  
  43. See Also:
  44.   expressions
  45.   ALIAS special
  46.